package com.cxcs.cxcsojbackendjudgeservice.judge.codesandbox;

import com.cxcs.cxcsojbackendjudgeservice.judge.codesandbox.impl.ExampleCodeSandBox;
import com.cxcs.cxcsojbackendjudgeservice.judge.codesandbox.impl.RemoteCodeSandBox;
import com.cxcs.cxcsojbackendjudgeservice.judge.codesandbox.impl.ThirdPartyCodeSandBox;

/**
 * 代码沙箱工厂（静态工厂模式）
 *    根据传入的字符串 指定要实现的实现类
 *
 * @Author: CxCS
 * @Version: 1.0
 * @Date: 2024-08
 */
public class CodeSandBoxFactory {
    /**
     *  创建代码沙箱 实现对象
     * @param type
     * @return
     */
    public static CodeSandBox newInstance(String type) {
        switch (type) {
            case "example":
                return new ExampleCodeSandBox();
            case "remote":
                return new RemoteCodeSandBox();
            case "thirdParty":
                return new ThirdPartyCodeSandBox();
            default:
                return new ExampleCodeSandBox();
        }
    }
}
